<?php
include("functions.php");
include("libs/smarty.class.php");

$smarty = new Smarty();

if(isset($_POST['login']))
    {
        $email = $_POST['email'];
        $password = md5($_POST['password']);

        $sql=mysql_query("SELECT id FROM user_student WHERE email='$email' and password='$password'");

        $row=mysql_fetch_array($sql);
        $count=mysql_num_rows($sql);

        if($count == 1)
            {
            session_register("user");
            $_SESSION['user_email'] = $email;
            $_SESSION['user_id'] = $row['id'];
            echo '
            <script type="text/javascript">
                location.href="index.php";
            </script> ';
        }
        else
            {
            echo "Twój login i hasło jest nieprawidłowe!";
        }
    }

$smarty->display('header.tpl');
?>
